<template>
	<div class="page-wrap">
		<page-title></page-title>
		<div class="back">
			<el-button @click="goback" type="primary" size="small">返回</el-button>
		</div>
		<div class="page-content">
			<div class="page-row">
				<div class="box-right">
					<div class="table-box">
						<el-tabs v-model="activeTab" class="flex-tabs">
							<el-tab-pane name="1" label="基本设置" lazy>
								<basicSet ref="basic" :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></basicSet>
							</el-tab-pane>
							<el-tab-pane name="2" :disabled="this.showactiveTab < 2" label="核素设置" lazy>
								<nuclideSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></nuclideSet>
							</el-tab-pane>
							<el-tab-pane name="3" :disabled="this.showactiveTab < 3" label="沉降设置" lazy>
								<sedimentation :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></sedimentation>
							</el-tab-pane>
							<el-tab-pane name="4" :disabled="this.showactiveTab < 4" label="扩散设置" lazy>
								<diffusionSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></diffusionSet>
							</el-tab-pane>
							<el-tab-pane name="5" :disabled="this.showactiveTab < 5" label="时间设置" lazy>
								<timeSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></timeSet>
							</el-tab-pane>
							<el-tab-pane name="6" :disabled="this.showactiveTab < 6" label="烟团设置" lazy>
								<puffSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></puffSet>
							</el-tab-pane>
							<el-tab-pane name="7" :disabled="this.showactiveTab < 7" label="气象设置" lazy>
								<weatherSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></weatherSet>
							</el-tab-pane>
							<el-tab-pane name="8" :disabled="this.showactiveTab < 8" label="输出设置" lazy>
								<outputSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></outputSet>
							</el-tab-pane>
							<el-tab-pane name="9" :disabled="this.showactiveTab < 9" label="其他设置" lazy>
								<otherSet :batchid="batchid" v-on:changeActiveTab="changeActive($event)"></otherSet>
							</el-tab-pane>
						</el-tabs>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import basicSet from "./basicSet"
import nuclideSet from "./nuclideSet"
import sedimentation from "./sedimentation"
import puffSet from "./puffSet"
import weatherSet from "./weatherSet"
import diffusionSet from "./diffusionSet"
import timeSet from "./timeSet"
import outputSet from "./outputSet"
import otherSet from "./otherSet"
import { mapState } from "vuex"

import { BATCH_CREATE } from "@/service/hd5.js"
export default {
	components: {
		basicSet,
		nuclideSet,
		sedimentation,
		puffSet,
		weatherSet,
		diffusionSet,
		timeSet,
		outputSet,
		otherSet,
	},
	data() {
		return {
			activeTab: "1",
			batchid: this.$route.query.id,
		}
	},
	computed: {
		...mapState({
			showactiveTab: (state) => state.token.basic_show_Tab,
			basic_Data: (state) => state.token.basic_Data,
		}),
	},
	created() {
		this.getBasicData()
	},
	mounted() { 
		this.$emit("changeActiveTab", this.activeTab)
		this.$store.dispatch("change_basic_showTab", this.activeTab)
		this.router()
	},
	methods: {
		//配置面包屑
		router() {
			// let temproute = [...this.$route.query.routeList]
			let temproute = []

			let advert = {
				resrName: "基本模块",
			}
			temproute.push(advert)
			this.$store.commit("updateRoute", temproute)
		},
		goback() {
			this.$router.go(-1)
		},
		changeActive(value) {
			this.activeTab = value
		},
		getBasicData() {
			let params = {
				batchid: this.$route.query.id,
				batchinfo: "BASE",
			}			
			this.$appApi
				.BATCH_DETAIL(params)
				.then((res) => {
					var str = res.data.substring(0, 1)
					if (str == "E") {
						let message = res.data.substring(6)
						this.$notify.error({
							title: "请求失败！",
							message: message,
							type: "success",
						})
					} else if (str == "S") {
						var data = JSON.parse(res.data.substring(8))
						let tempdata = data
						this.$store.dispatch("change_basic_showTab", tempdata.SETPAGEINDEX)
						this.$store.dispatch("upData_basic_Data", tempdata)
						this.$refs.basic.setData()
					}
				})
				.catch((err) => {
					console.log(err)
				})
		},
	},
}
</script>